package com.zttek.videoShareProject.modules.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zttek.videoShareProject.modules.model.Keyword;
import com.zttek.videoShareProject.modules.mapper.KeywordMapper;
import com.zttek.videoShareProject.modules.service.IKeywordService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author CBY
 * @since 2018-07-03
 */
@Service
public class KeywordServiceImpl extends ServiceImpl<KeywordMapper, Keyword> implements IKeywordService {

    @Autowired
    private KeywordMapper keywordMapper;
    public List<Keyword> getKeyWordList() {
        EntityWrapper<Keyword> wrapper=new EntityWrapper<Keyword>();
        wrapper.orderBy("keyword_id",false);
        List<Keyword> list=keywordMapper.selectList(wrapper);
        return list.size()>0?list:null;
    }

    public boolean addKeyWord(String keyWord) {
        Keyword keyword=new Keyword();
        keyword.setKeyword(keyWord);
        Date date=new Date();
        keyword.setCreateDate(date);
        return  keywordMapper.insert(keyword)!=0;
    }

    public boolean deleteKeyWord(Long id) {

        return keywordMapper.deleteById(id)!=0;
    }
}
